<?php

/**
 * This is the model class for table "setoran".
 *
 * The followings are the available columns in table 'setoran':
 * @property integer $nomor
 * @property string $no_bayar
 * @property integer $kode_sptpd
 * @property string $thn_pajak
 * @property double $pajak_bphtb
 * @property string $tgl_bayar
 * @property string $jenis_sk
 * @property double $jml_bayar
 * @property integer $kode_vib
 * @property string $via_bayar
 * @property string $no_rev
 * @property string $sts
 *
 * The followings are the available model relations:
 * @property Sptpd $kodeSptpd
 * @property ViaBayar $kodeVib
 */
class Setoran extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'setoran';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('no_bayar, kode_sptpd, thn_pajak, pajak_bphtb, tgl_bayar, jenis_sk, jml_bayar, kode_vib, via_bayar, no_rev, sts', 'required'),
			array('kode_sptpd, kode_vib', 'numerical', 'integerOnly'=>true),
			array('pajak_bphtb, jml_bayar', 'numerical'),
			array('no_bayar', 'length', 'max'=>11),
			array('thn_pajak', 'length', 'max'=>4),
			array('jenis_sk, sts', 'length', 'max'=>1),
			array('via_bayar', 'length', 'max'=>25),
			array('no_rev', 'length', 'max'=>30),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('nomor, no_bayar, kode_sptpd, thn_pajak, pajak_bphtb, tgl_bayar, jenis_sk, jml_bayar, kode_vib, via_bayar, no_rev, sts', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'kodeSptpd' => array(self::BELONGS_TO, 'Sptpd', 'kode_sptpd'),
			'kodeVib' => array(self::BELONGS_TO, 'ViaBayar', 'kode_vib'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'nomor' => 'Nomor',
			'no_bayar' => 'No Bayar',
			'kode_sptpd' => 'Kode Sptpd',
			'thn_pajak' => 'Thn Pajak',
			'pajak_bphtb' => 'Pajak Bphtb',
			'tgl_bayar' => 'Tgl Bayar',
			'jenis_sk' => 'Jenis Sk',
			'jml_bayar' => 'Jml Bayar',
			'kode_vib' => 'Kode Vib',
			'via_bayar' => 'Via Bayar',
			'no_rev' => 'No Rev',
			'sts' => 'Sts',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('nomor',$this->nomor);
		$criteria->compare('no_bayar',$this->no_bayar,true);
		$criteria->compare('kode_sptpd',$this->kode_sptpd);
		$criteria->compare('thn_pajak',$this->thn_pajak,true);
		$criteria->compare('pajak_bphtb',$this->pajak_bphtb);
		$criteria->compare('tgl_bayar',$this->tgl_bayar,true);
		$criteria->compare('jenis_sk',$this->jenis_sk,true);
		$criteria->compare('jml_bayar',$this->jml_bayar);
		$criteria->compare('kode_vib',$this->kode_vib);
		$criteria->compare('via_bayar',$this->via_bayar,true);
		$criteria->compare('no_rev',$this->no_rev,true);
		$criteria->compare('sts',$this->sts,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Setoran the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
